When creating a VBD, save the devid in the device info structure. If creation
authorEwan Mellor <ewan@xensource.com>
Tue, 20 Mar 2007 11:44:13 +0000 (11:44 +0000)
committerEwan Mellor <ewan@xensource.com>
Tue, 20 Mar 2007 11:44:13 +0000 (11:44 +0000)
fails, remove the device config entry.

Signed-off-by: Tom Wilkie <tom.wilkie@gmail.com>
tools/python/xen/xend/XendDomainInfo.py

index 99c3ddd4254e9db763c1f4c457c5a7c209f7e40c..a1d3c16f88f4996edaa35bf3225acb6bbe0fc2e7 100644 (file)
@@ -2301,12 +2301,21 @@ class XendDomainInfo:
             dev_control = None
             
             if vdi_image_path.startswith('tap'):
-                dev_control =  self.getDeviceController('tap')
+                dev_control = self.getDeviceController('tap')
             else:
                 dev_control = self.getDeviceController('vbd')
-                
-            config['devid'] = dev_control.createDevice(config)
 
+            try:
+                devid = dev_control.createDevice(config)
+                dev_control.waitForDevice(devid)
+                self.info.device_update(dev_uuid,
+                                        cfg_xenapi = {'devid': devid})
+            except Exception, exn:
+                log.exception(exn)
+                del self.info['devices'][dev_uuid]
+                self.info['vbd_refs'].remove(dev_uuid)
+                raise
+            
         return dev_uuid
 
     def create_phantom_vbd_with_vdi(self, xenapi_vbd, vdi_image_path):